<template>
  <div>
    <p>{{ $store.state.count }}</p>
    <button @click="add">加一</button>
    <button @click="minus">减一</button>
    <button @click="addOdd">偶数时加二</button>
    <button @click="minusOdd">奇数时减二</button>
    
  </div>
</template>

<script>
// import { mapMutations,mapActions } from 'vuex';
export default {
  created(){
    console.log(this.$store.state.count);
  },
  methods:{
    // ...mapMutations(['add','minus']),
    // ...mapActions(['addOdd','minusOdd'])
    add(){
      this.$store.commit('add')

    },
    minus(){
      this.$store.commit('minus')
    },
    addOdd(){
      this.$store.dispatch('addOdd')
    },
    minusOdd(){
      this.$store.dispatch('minusOdd')
    }
  }
};
</script>

<style lang="scss" scoped>
</style>